﻿@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@section header{
    <style>
        /*.fast-filter .tablink {
            padding-right: 8px;
            padding-left: 2px;
        }*/
    </style>
}

<div class="detail-panel-div" style="">
    @*页面视图列表开始*@
    @*<table class="list_table table100 fast-filter" style="line-height:25px;">
            <tbody>
                <tr>
                    <td style="">
                        <i class="icon-filter pure-icon-bu"></i><span>
                            显示：<a class="cus_markbai tablink" href="javascript:void(0);" @@click="searchReset">全部</a>
                        </span>
                        <i class="icon-filter pure-icon-bu"></i><span>
                                状态：<a class="cus_markbai tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="reset" data-fname="donestate">不限</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-fname="donestate" data-fvalue="@((int)BillState.未结算)">待结算</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-fname="donestate" data-fvalue="@((int)BillState.待付款)">已结算</a>
                            </span>
                            <i class="icon-filter pure-icon-bu"></i>
                            <span>
                                时间：<a class="cus_markbai tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="reset" data-fstart="studentdate_s" data-fend="studentdate_e">不限</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="date" data-fstart="studentdate_s" data-fend="studentdate_e" data-fvalue="nowd">当天</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="date" data-fstart="studentdate_s" data-fend="studentdate_e" data-fvalue="noww">本周</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="date" data-fstart="studentdate_s" data-fend="studentdate_e" data-fvalue="nowm">本月</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="date" data-fstart="studentdate_s" data-fend="studentdate_e" data-fvalue="nowy">本年</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="date" data-fstart="studentdate_s" data-fend="studentdate_e" data-fvalue="lastw">上周</a>
                                <a class="cus_markhui tablink" href="javascript:void(0);" @@click="listFastFilter($event)" data-ftype="date" data-fstart="studentdate_s" data-fend="studentdate_e" data-fvalue="lastm">上月</a>
                            </span>
        </td>
        </tr>
        </tbody>
        </table>*@
    @*页面视图列表结束*@
    <div id="searchDiv" style="z-index: 1; display: block; position: relative; margin-top: 3px;" v-show="searchShow">
        <table cellpadding="5" cellspacing="2" class="searchUIBasic padding2" align="center" border="0" style="width:90%;border:none;">
            <tbody>
                <tr>
                    <td class="small" nowrap="" align="center">
                        <span>业务类别</span>
                        <input type="text" class="txtBox" style="width: 160px" readonly v-model.trim="listConditions.typename">
                        <button class="pure-button pure-button-share pure-icon-bu" style="width:23px;height:21px;" onclick="openPopBuzTypeS(this); return false;">
                            <i class="icon-search"></i>
                        </button>
                        <button class="pure-button pure-button-approve pure-icon-bu" style="width: 23px; height: 21px;" title="清除" onclick="clearPopBuzTypeS(this);return false;">
                            <i class="icon-remove"></i>
                        </button>
                        <span>名称</span>
                        <input type="text" class="txtBox" style="width: 160px" v-model.trim="listConditions.name">
                        &nbsp;
                        <button class="pure-button pure-button-edit" title="查找" @@click.prevent="listRefresh(1)">
                            <i class="icon-search"></i>查找
                        </button>
                        &nbsp;
                        <button class="pure-button pure-button-cancel" title="取消" @@click.prevent="searchReset">
                            <i class="icon-rotate-left"></i>重置
                        </button>
                        &nbsp;&nbsp;
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <table class="lvt small table100" style="">
        <tr>
            <td style="padding-left: 30px;" align="left" nowrap>
                <button class="pure-button pure-button-edit" @@click.prevent="listAdd">
                    <i class="icon-plus"></i>&nbsp;新增
                </button>
                @*&nbsp;
                    <button class="pure-button pure-button-danger" @@click.prevent="listBatchDelete">
                        <i class="icon-trash"></i>&nbsp;批量删除
                    </button>*@
            </td>
            <td nowrap align="right" valign="middle">
                <table border="0" cellspacing="0" cellpadding="0" class="small">
                    <tbody>
                        <tr>
                            <td style="padding-right: 5px">
                                <vue-pagination :total="listData.total" :psize="listData.psize" :pnum="listData.pnum" @@change="pageChangeHandler"></vue-pagination>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </table>
    <div style="width:100%;overflow:auto;">
        <table class="crm-table table100 padding2" cellspacing="1" cellpadding="3" style="table-layout:fixed;">
            <caption v-show="listData.list.length==0">
                暂无数据
            </caption>
            <tr class="windLayerHead">
                <td style="width: 30px;text-align:center;">
                    <input type="checkbox" name="selectall" @@click="listToggle($event)" v-model="listData.checked" />
                </td>
                @*<td style="width: 30px;">状态</td>*@
                <td v-for="(col,idx) in listColumns" :style="col.hdStyles">
                    <a class='listFormHeaderLinks' @@click="listSort(col.name)" v-if="col.sort">{{col.title}}<i :class="{'icon-caret-up':listSortColumn.order=='asc','icon-caret-down':listSortColumn.order=='desc'}" v-if="col.name==listSortColumn.name"></i></a>
                    <span v-else>{{col.title}}</span>
                </td>
                <td nowrap style="width:40px;">
                    操作
                </td>
            </tr>
            <tr v-for="(item,idx) in pageList" :rid="item.ID" :class="{'crm-table-plural':idx%2==1}" style="cursor: pointer;">
                <td style="text-align:center;">
                    <input type="checkbox" name="rowid" :value='item.ID' :data-idx="idx" @@click="listCheck($event)" :checked="item.CheckedState" />
                </td>
                @*<td style="text-align:center;">
                        <div style="border-radius:50%;width:12px;height:12px;margin:0 auto;" :style="item.Style" :title="item.StateNowText"></div>
                    </td>*@
                <td v-for="(col,cidx) in listColumns" :style="item.Styles[cidx]">
                    <a :href="item.Links[cidx].href" v-if="item.Links[cidx].href">{{item[col.name]}}</a>
                    <span v-else-if="col.format" v-html="col.format(item[col.name],item)"></span>
                    <span v-else>{{item[col.name]}}</span>
                </td>
                <td nowrap>
                    <i class="icon-edit pure-icon-bu crm-bu-style list-action-btn" title='修改' style="" @@click="listEdit(item)"></i>
                    <i class="icon-trash pure-icon-bu crm-bu-style list-action-btn" title='删除' style="" @@click="listDelete(item)"></i>
                </td>
            </tr>
        </table>
    </div>

    <div id="listEditDiv" class="windLayerDiv" style="display: none;">
        <table class="windLayerHeadingULine table100" cellpadding="3" cellspacing="0">
            <tr class="windLayerHeadingTr">
                <td width="80%" style="cursor: move;" class="windLayerHeading" align="left">
                    业务编码
                </td>
                <td align="right">
                    <input class="windLayerBtclose" type="button" title="关闭" onclick="popClose();">&nbsp;&nbsp;
                </td>
            </tr>
        </table>
        <form id="listEditFrm">
            <table style="background-color: rgb(234, 234, 234);width:100%;" class="small" border="0" cellpadding="3" cellspacing="1">
                <tr class="detail-content-heading" style="height: 28px;">
                    <td colspan="2">
                        <b>&nbsp;&nbsp;基本信息</b>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle label-required" align="right" width="30%">
                        业务类型
                    </td>
                    <td class="windLayerInfo" align="left" width="70%">
                        <input type="text" v-model.trim="model.BuzTypeText" readonly class="detailedViewTextBox" style="width: 70%;cursor:pointer;" onclick="openPopBuzTypeE(this); return false;" />
                        <button class="pure-button pure-button-share pure-icon-bu" style="width:23px;height:21px;" onclick="openPopBuzTypeE(this); return false;">
                            <i class="icon-search"></i>
                        </button>
                        <button class="pure-button pure-button-approve pure-icon-bu" style="width: 23px; height: 21px;" title="清除" onclick="clearPopBuzTypeE(this);return false;">
                            <i class="icon-remove"></i>
                        </button>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle label-required" align="right">
                        编码类型
                    </td>
                    <td class="windLayerInfo" align="left">
                        <select name="" v-model="model.Code" class="validate[required]">
                            <option value="">请选择</option>
                            <option :value="c.value" v-for="(c) in codes">{{c.text}}</option>
                        </select>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        名称
                    </td>
                    <td class="windLayerInfo" align="left">
                        <input type="text" v-model.trim="model.Name" class="detailedViewTextBox" style="width: 90%;" />
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle label-required" align="right">
                        编码规则
                    </td>
                    <td class="windLayerInfo" align="left">
                        <input type="text" v-model.trim="model.RuleTpl" class="detailedViewTextBox validate[required]" style="width: 90%;" />
                        <br /><span style="color: rgb(0, 112, 186);">编码规则中的保留变量：<br />序号&nbsp;-&nbsp;${no}<br />日期时间&nbsp;-&nbsp;${yyyyMMddHHmmss}，如20200101151259<br /></span>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        当前值
                    </td>
                    <td class="windLayerInfo" align="left">
                        <input type="number" v-model.trim="model.Current" class="detailedViewTextBox" style="width: 80px;" /><span style="color: rgb(0, 112, 186);padding-left:5px;">新增之后无法修改，请仔细填写</span>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        步进值
                    </td>
                    <td class="windLayerInfo" align="left">
                        <input type="number" v-model.trim="model.Step" class="detailedViewTextBox" style="width: 80px;" /><span style="color: rgb(0, 112, 186);padding-left:5px;">新增之后无法修改，请仔细填写</span>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        序号最小长度
                    </td>
                    <td class="windLayerInfo" align="left">
                        <input type="number" v-model.trim="model.MinLen" class="detailedViewTextBox" style="width: 80px;" /><span style="color: rgb(0, 112, 186);padding-left:5px;"></span>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        是否系统保留
                    </td>
                    <td class="windLayerInfo">
                        <input type="checkbox" class="" v-model="model.Reserved" style="" /><span style="color: rgb(0, 112, 186);">系统保留则不允许修改业务类型、编码类型且不允许删除</span>
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        是否允许修改
                    </td>
                    <td class="windLayerInfo">
                        <input type="checkbox" class="" v-model="model.Freezed" style="" />
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        排序
                    </td>
                    <td class="windLayerInfo" align="left">
                        <input type="number" v-model="model.Sort" value="" class="detailedViewTextBox" style="width:80px;" />
                    </td>
                </tr>
                <tr bgcolor="white" height="25px;">
                    <td class="windLayerTitle" align="right">
                        说明
                    </td>
                    <td class="windLayerInfo" align="left">
                        <input type="text" v-model.trim="model.Comment" class="detailedViewTextBox" style="width: 90%;" />
                    </td>
                </tr>
                <tr bgcolor="white" height="40px;">
                    <td colspan="2" align="center">
                        <button type="button" class="pure-button pure-button-success save" onclick="$('#listEditFrm').submit();">
                            <i class="icon-check"></i>保存
                        </button>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="button" class="pure-button pure-button-cancel" onclick="popClose();return false;">
                            <i class="icon-reply"></i>取消
                        </button>
                        &nbsp;
                    </td>
                </tr>
            </table>
        </form>
        <div class="windLayerFoot">
            &nbsp;
        </div>
        <div class="windLayerCorner">
            &nbsp;
        </div>
    </div>
</div>
@*生成列表操作*@
@section footer{
    @*日期必须开始*@
    <script src="~/lib/laydate/laydate.js" asp-append-version="true"></script>
    <script src="~/lib/moment/moment.min.js" asp-append-version="true"></script>
    @*验证开始*@
    <script src="~/lib/validationEngine/jquery.validationEngine.min.js" asp-append-version="true"></script>
    <script src="~/lib/validationEngine/jquery.validationEngine-zh_CN.js" asp-append-version="true"></script>
    <link href="~/lib/validationEngine/validationEngine.jquery.css" rel="stylesheet" asp-append-version="true" />
    @*验证结束*@
    @*日期必须结束*@
    <script type="text/javascript">
		@* 列表相关开始 *@
		var listConditionsInit = { type: "" };//初始查询条件
		var pageEnumData = {
			codes:@(Json.Serialize(ViewBag.CodeOptions)),
		};
		var pageData = $.extend(pageBaseData, {
			hideBreadcrumb: false,
			codes: pageEnumData.codes,
			listData: {
				checked:false,
				list: [],
				total: 0,
				pnum: 1,
				psize: 20,
				sumcol: [],
				listsumtotal: [],
				pagesumtotal: []
			},
			listColumns: [
				{
					title: "业务类型",
					name: "BuzTypeText",
					hdStyles: {
						width: "120px",
					},
					bdStyles: {
					}
				},
				{
					title: "业务编码",
					name: "Code",
					hdStyles: {
						width: "160px",
					},
					bdStyles: {
					},
					format: function (val, item) {
						var obj = pageEnumData.codes.find(function (cur) {
							return cur.value == val;
						});
						return obj ? obj.text : val;
					}
				},
				{
					title: "编码规则",
					name: "RuleTpl",
					hdStyles: {
						width: "160px",
					},
					bdStyles: {
					}
				},
				{
					title: "名称",
					name: "Name",
					hdStyles: {
						width: "120px",
					},
					bdStyles: {
					}
				},
				{
					title: "当前值",
					name: "Current",
					hdStyles: {
						width: "60px",
						textAlign:'center',
					},
					bdStyles: {
						textAlign:'center',
					}
				},
				{
					title: "步进值",
					name: "Step",
					hdStyles: {
						width: "60px",
						textAlign:'center',
					},
					bdStyles: {
						textAlign:'center',
					}
				},
                {
                    title: "序号最小长度",
                    name: "MinLen",
                    hdStyles: {
                        width: "80px",
                        textAlign: 'center',
                    },
                    bdStyles: {
                        textAlign: 'center',
                    }
                },
				{
					title: "参数说明",
					name: "Comment",
					hdStyles: {
						width: "150px",
					},
					bdStyles: {
					}
				},
				{
					title: "排序",
					name: "Sort",
					hdStyles: {
						width: "60px",
						textAlign:'center',
					},
					bdStyles: {
						textAlign:'center',
					}
				},
				{
					title: "是否系统预留",
					name: "Reserved",
					hdStyles: {
						width: "80px",
						textAlign:'center',
					},
					bdStyles: {
						textAlign:'center',
					}, format: function (val, item) {
						if (val) {
							return "<i class='icon-check'></i>";
						} else {
							return "";
						}
					}
				},
				{
					title: "是否允许修改",
					name: "Freezed",
					hdStyles: {
						width: "80px",
						textAlign:'center',
					},
					bdStyles: {
						textAlign:'center',
					}, format: function (val, item) {
						if (val) {
							return "<i class='icon-check'></i>";
						} else {
							return "";
						}
					}
				},
				{
					title: "创建日期",
					name: "AddDate",
					hdStyles: {
						width: "120px",
						textAlign:'center',
					},
					bdStyles: {
						textAlign:'center',
					}
				},
				{
					title: "创建人",
					name: "AddManName",
					hdStyles: {
						width: "60px",
						textAlign:'center',
					},
					bdStyles: {
						textAlign:'center',
					}
				},
			],
			searchShow:true,
			listConditions: Object.assign({}, listConditionsInit),
			listSortColumn: {
				name: "",
				order:""
			},
			listStyles: {
				@*"StateNow": {
					"@((int)ST.Buz.Base.Enums.BillState.已付款)": { backgroundColor:"#FFCC00"},
					"@((int)ST.Buz.Base.Enums.BillState.已作废)": { backgroundColor:"#FF0000"},
					"@((int)ST.Buz.Base.Enums.BillState.已删除)": { backgroundColor:"#cc4646"},
					"@((int)ST.Buz.Base.Enums.BillState.已退款)": { backgroundColor:"#E2AF08"},
					"@((int)ST.Buz.Base.Enums.BillState.待付款)": { backgroundColor:"#009963"},
					"@((int)ST.Buz.Base.Enums.BillState.未结算)": { },
				}*@
			},
			listColStyles: {
			},
			model: {},
		});

		var pageApp = new Vue({
			el: '#app',
			data: pageData,
			mounted: function () {
				this.listRefresh();
			},
			methods: {
				pageBack: function () {
					//history.go(-1);
					history.back();
				},
				viewMenu: function (menu) {
					if (menu.Code == this.curmenu) {
						return;
					}
					location.href = menu.Url;
				},
				pageChangeHandler: function (args) {
					this.listRefresh(args.pnum, args.psize)
				},
				listFastFilter: function (e) {
				},
				listRefresh: function (pageNum, pageSize) {
					var _params = Object.assign({}, {
						pnum: pageNum || this.listData.pnum,
						psize: pageSize || this.listData.psize,
						sortorder: !this.listSortColumn.name ? "" : this.listSortColumn.name + "_" + this.listSortColumn.order
					}, this.listConditions);
					var _this = this;
					utils.ajaxPost('@(Url.Action("Search", "Sys_BuzRowNum"))', _params, function (resp) {
						var list = resp.data.list.map(function (item) {
							return Object.assign({}, item, {
								CheckedState: false,
							});
						});
						var newData = { list: list, total: resp.data.total, pnum: resp.data.pnum, psize: resp.data.psize ,checked:false};
						_this.listData = newData;
					}, function (err) {
					})
				},
				searchReset: function () {
					this.listConditions = Object.assign({}, listConditionsInit);
					this.listSortColumn = {
						col: "",
						order: ""
					};
					this.listRefresh(1);
				},
				searchToggle: function () {
					this.searchShow = !this.searchShow;
				},
				listSort: function (col) {
					if (col != this.listSortColumn.name) {
						this.listSortColumn.order = "desc";
						this.listSortColumn.name = col;
					} else {
						this.listSortColumn.order = this.listSortColumn.order == "asc" ? "desc" : "asc";
					}
					this.listRefresh(1);
				},
				listToggle: function (e) {
					var checked = (e.srcElement || e.target).checked;
					this.listData.list=this.listData.list.map(function (item) {
						return Object.assign({}, item,{
							CheckedState: checked
						});
					});
				},
				listCheck: function (e) {
					var obj = e.srcElement || e.target;
					var checked = obj.checked;
					this.listData.list.splice(obj.dataset.idx, 1, Object.assign({}, this.listData.list[obj.dataset.idx], {
						CheckedState: checked
					}));
				},
				listAdd: function () {
					$('#listEditFrm').validationEngine('hide');
					$('#listEditDiv').find('.windLayerHeading').html('新增业务编码');
					this.model = {
						BuzType: 0,
						Sort: 0,
						Current: 1,
						Step:1,
						Code:"",
						Reserved: false,
						Freezed:false
					};
					popOpen('#listEditDiv','520px');
				},
				listEdit: function (item) {
					if (!item) {
						return;
					}
					var self = this;
					utils.ajaxPost('@(Url.Action("ViewJson", "Sys_BuzRowNum"))', { id: item.ID }, function (resp) {
						$('#listEditFrm').validationEngine('hide');
						self.model = resp.data;
						$('#listEditDiv').find('.windLayerHeading').html('修改业务编码');
						popOpen('#listEditDiv','520px');
					}, function (msg) {
						utils.alert(msg);
					});
				},
				listDelete: function (item) {
					var _this = this;
					utils.confirm('确定要删除业务编码【' + item.Name +'】？', function () {
						utils.ajaxPost('@(Url.Action("Delete","Sys_BuzRowNum"))', { id: item.ID }, function (resp) {
							utils.success("删除成功");
							_this.listRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				listBatchDelete: function () {
					var selected = this.listData.list.filter(function (item) {
						return item.CheckedState;
					});
					var ids = selected.map(function (item) {
						return item.ID;
					});
					if (!ids||ids.length == 0) {
						utils.alert('请先选择要删除的业务编码');
						return;
					}
					var _this = this;
					utils.confirm('确定要删除所选择的业务编码？', function () {
						utils.ajaxPost('@(Url.Action("BatchDelete", "Sys_BuzRowNum"))',  ids , function (resp) {
							utils.success("删除成功");
							_this.listRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				listSave: function () {
					var _this = this;
					utils.ajaxPost('@(Url.Action("Save", "Sys_BuzRowNum"))', _this.model, function (resp) {
						popClose();
						_this.listRefresh();
					}, function (msg) {
						utils.alert(msg);
					});
				}
			},
			computed: {
				pageList: function () {
					var _this = this;
					return this.listData.list.map(function (item) {
						return Object.assign({}, item, {
							Styles: _this.listColumns.map(function (col) {//列样式
								return Object.assign({}, col.bdStyles, _this.listColStyles[col.name] ? _this.listColStyles[col.name][item[col.name]] : {})
							}),
							Style: {},
							//Style: _this.listStyles.StateNow[item.StateNow],//行样式
							Links: _this.listColumns.map(function (col) {
								return Object.assign({}, { href: col.href ? col.href.replace(/{ID}/g, item.ID) : "" });
							}),
						});
					});
				},
				currentM: function () {
					var currentM = null;
					var i;
					var j;
					for (i = 0; i < this.global.modules.length; i++) {
						for (j = 0; j < this.global.modules[i].Services.length; j++) {
							if (this.serviceCode == this.global.modules[i].Services[j].Code) {
								currentM = this.global.modules[i];
								break;
							}
						}
					}
					return currentM;
				},
				currentS: function () {
					var currentS = null;
					var i;
					var j;
					for (i = 0; i < this.global.modules.length; i++) {
						for (j = 0; j < this.global.modules[i].Services.length; j++) {
							if (this.serviceCode == this.global.modules[i].Services[j].Code) {
								currentS = this.global.modules[i].Services[j];
								break;
							}
						}
					}
					return currentS;
				}
			},
			filters: {
			}
		});
		@* 列表相关结束 *@
		var popLayerIndex;
		function popOpen(id,width) {
			popLayerIndex=layer.open({
				type: 1,
				title: false,
				closeBtn: 0,
				area: width||'520px',
				skin: 'layui-layer-nobg', //没有背景色
				shadeClose: false,
				content: $(id)
			});
		}

		function popClose() {
			layer.close(popLayerIndex|| layer.index);
		}

		$(document).ready(function () {
			$("#listEditFrm").validationEngine({
				scroll: false,
				validateNonVisibleFields: false,
				autoHidePrompt: true,
				promptPosition:'topLeft',
				showOneMessage: true,
				ajaxFormValidationMethod: 'post',
				onValidationComplete: function (form, status) {
					if (!status) {
						return;
					}
					pageApp.listSave();
				}
			});
		});

		function openPopBuzType(type, obj) {
			var $obj = $(obj);
			var cb;
			if (type == 's') {
				cb = 'popBuzTypeSCallback';
			} else {
				cb = 'popBuzTypeECallback';
			}
			utils.layerPop('@(Url.Action("PopList","Sys_EnumCode"))?callback='+cb, '240px', '320px', $obj.is('input')?$obj:$obj.prev('input'));
		}

		function openPopBuzTypeS(obj) {
			openPopBuzType('s',obj);
		}

		function openPopBuzTypeE(obj) {
			openPopBuzType('e',obj);
		}

		function popBuzTypeSCallback(ret, index) {
			layer.close(index);
			if (!ret.id || ret.id == "0") {
				return;
			}
			pageData.listConditions = Object.assign({}, pageData.listConditions, {
				type:ret.id,
				typename:ret.name
			});
			pageApp.listRefresh(1);
		}

		function popBuzTypeECallback(ret, index) {
			layer.close(index);
			if (!ret.id || ret.id == "0") {
				return;
			}
			var name = '';
			var pNode = ret.getParentNode();
			while (pNode && pNode.id) {
				name += pNode.name + "-";
				pNode = pNode.getParentNode();
			}
			name += ret.name;
			pageData.model = Object.assign({}, pageData.model, {
				BuzType: ret.id,
				BuzTypeText:name
			});
		}

		function clearPopBuzTypeS() {
			pageData.listConditions = Object.assign({}, pageData.listConditions, {
				type:"0",
				typename:""
			});
			pageApp.listRefresh(1);
		}

		function clearPopBuzTypeE() {
			pageData.listConditions = Object.assign({}, pageData.listConditions, {
				BuzType:"",
				BuzTypeText:""
			});
			pageApp.listRefresh(1);
		}
    </script>
}
